package cn.mutsuki.micrometer.core;

import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.Gauge;
import io.micrometer.core.instrument.MeterRegistry;

import java.util.ArrayList;
import java.util.List;
@Deprecated
public class MtkMeterConfiguration {
    private List<MeterProperties> typedMeterProperties = new ArrayList<>();

    public void addMeterProperty(MeterProperties meterProperties){
        typedMeterProperties.add(meterProperties);
    }

    public void apply(MeterRegistry meterRegistry){
        typedMeterProperties.forEach(meterProperties -> {
            switch(meterProperties.getMeterType()){
                case COUNTER:{
                    meterProperties.getIdentities().forEach((meterName , meterTags) -> {
                        Counter.builder(meterName).tags(meterTags).register(meterRegistry);
                    });
                };break;
                case GAUGE:{
                    meterProperties.getIdentities().forEach((meterName , meterTags) -> {
                        Gauge.builder(meterName , () -> 0d).tags(meterTags).register(meterRegistry);
                    });
                };break;
                default:;
            }
        });
    }

}
